package com.ruoyi.hr.service.impl.entryexitmanage.entrymanage;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.hr.mapper.entryexitmanage.entrymanage.EntryBackgroundMapper;
import com.ruoyi.hr.service.entryexitmanage.entrymanage.EntryBackgroundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class EntryBackgroundServiceImpl implements EntryBackgroundService {

    @Autowired
    EntryBackgroundMapper entryBackgroudMapper;

    /**
     * 获取教育信息
     *
     * @param id
     * @return
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getEducationList(String id) {
        List<Map<String,Object>> maps = entryBackgroudMapper.getEducationList(id);
        for(Map map : maps){
            if (map.containsKey("isout")) {
                if(map.get("isout").toString().equals("false")){
                    map.put("isout","否");
                }else if(map.get("isout").toString().equals("true")){
                    map.put("isout","是");
                }
            }
        }
        return maps;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addEducation(Map map) {
        return entryBackgroudMapper.addEducation(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editEducation(Map map) {
        return entryBackgroudMapper.editEducation(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getEducation(String id) {
        Map<String, Object> map = entryBackgroudMapper.getEducation(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_Education_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteEducation(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteEducation(id);
        }
        return num;
    }

    /**
     * 获取工作经历
     *
     * @param id
     * @return
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getWorkingList(String id) {
        List<Map<String,Object>> maps = entryBackgroudMapper.getWorkingList(id);
        for(Map map : maps){
            if (map.containsKey("isout")) {
                if(map.get("isout").toString().equals("false")){
                    map.put("isout","否");
                }else if(map.get("isout").toString().equals("true")){
                    map.put("isout","是");
                }
            }
        }
        return maps;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addWorking(Map map) {
        return entryBackgroudMapper.addWorking(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getWorking(String id) {
        Map<String, Object> map = entryBackgroudMapper.getWorking(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_Working_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editWorking(Map map) {
        return entryBackgroudMapper.editWorking(map);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteWorking(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteWorking(id);
        }
        return num;
    }

    /**
     * 获取职称/资格证书
     *
     * @param id
     * @return
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getTitleList(String id) {
        return entryBackgroudMapper.getTitleList(id);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addTitle(Map map) {
        return entryBackgroudMapper.addTitle(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getTitle(String id) {
        Map<String, Object> map = entryBackgroudMapper.getTitle(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_Title_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editTitle(Map map) {
        return entryBackgroudMapper.editTitle(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteTitle(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteTitle(id);
        }
        return num;
    }

    /**
     * 获取培训经历
     *
     * @param id
     * @return
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getTrainingList(String id) {
        List<Map<String, Object>> maps = entryBackgroudMapper.getTrainingList(id);
        for (Map map : maps) {
            if (map.containsKey("IsJoin")) {
                if(map.get("IsJoin") != null){
                    String isJoin = map.get("IsJoin").toString();
                    if (isJoin.equals("0")) {
                        map.put("IsJoin", "前");
                    } else if (isJoin.equals("1")) {
                        map.put("IsJoin", "后");
                    }
                }
            }
        }
        return maps;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addTraining(Map map) {
        return entryBackgroudMapper.addTraining(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getTraining(String id) {
        Map<String, Object> map = entryBackgroudMapper.getTraining(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_training_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editTraining(Map map) {
        return entryBackgroudMapper.editTraining(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteTraining(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteTraining(id);
        }
        return num;
    }

    /**
     * 获取项目经历
     *
     * @param id
     * @return
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getProjectList(String id) {
        return entryBackgroudMapper.getProjectList(id);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addProject(Map map) {
        return entryBackgroudMapper.addProject(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getProject(String id) {
        Map<String, Object> map = entryBackgroudMapper.getProject(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_Project_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editProject(Map map) {
        return entryBackgroudMapper.editProject(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteProject(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteProject(id);
        }
        return num;
    }

    /**
     * 惩奖经历
     *
     * @param id
     * @return
     */
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getHortationList(String id) {
        List<Map<String, Object>> maps = entryBackgroudMapper.getHortationList(id);
        for (Map map : maps) {
            if (map.containsKey("InOut")) {
                String isJoin = map.get("InOut").toString();
                if (isJoin.equals("1")) {
                    map.put("InOut", "内");
                } else if (isJoin.equals("2")) {
                    map.put("InOut", "外");
                }
            }
        }
        return maps;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addHortation(Map map) {
        return entryBackgroudMapper.addHortation(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getHortation(String id) {
        Map<String, Object> map = entryBackgroudMapper.getHortation(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_Hortation_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editHortation(Map map) {
        return entryBackgroudMapper.editHortation(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteHortation(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteHortation(id);
        }
        return num;
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getFamilyList(String id) {
        return entryBackgroudMapper.getFamilyList(id);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addFamily(Map map) {
        return entryBackgroudMapper.addFamily(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getFamily(String id) {
        Map<String, Object> map = entryBackgroudMapper.getFamily(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("ebg_family_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editFamily(Map map) {
        return entryBackgroudMapper.editFamily(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteFamily(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteFamily(id);
        }
        return num;
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getLanguageList(String id) {
        return entryBackgroudMapper.getLanguageList(id);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addLanguage(Map map) {
        return entryBackgroudMapper.addLanguage(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getLanguage(String id) {
        Map<String, Object> map = entryBackgroudMapper.getLanguage(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_Language_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editLanguage(Map map) {
        return entryBackgroudMapper.editLanguage(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteLanguage(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteLanguage(id);
        }
        return num;
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getEmergencyList(String id) {
        return entryBackgroudMapper.getEmergencyList(id);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addEmergency(Map map) {
        return entryBackgroudMapper.addEmergency(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getEmergency(String id) {
        Map<String, Object> map = entryBackgroudMapper.getEmergency(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_emergency_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editEmergency(Map map) {
        return entryBackgroudMapper.editEmergency(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteEmergency(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteEmergency(id);
        }
        return num;
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getCertificateList(String id) {

        List<Map<String,Object>> maps = entryBackgroudMapper.getCertificateList(id);
        for(Map map : maps){
            if (map.containsKey("isDisable")) {
                if(map.get("isDisable").toString().equals("false")){
                    map.put("isDisable","有效");
                }else if(map.get("isDisable").toString().equals("true")){
                    map.put("isDisable","无效");
                }
            }
        }
        return maps;


    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int addCertificate(Map map) {
        return entryBackgroudMapper.addCertificate(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Map<String, Object> getCertificate(String id) {
        Map<String, Object> map = entryBackgroudMapper.getCertificate(id);
        List<String> Columns = entryBackgroudMapper.getTableColumn("eBG_certificate_register");
        for (String columns : Columns) {
            if (!map.containsKey(columns)) {
                map.put(columns, "");
            }
        }
        return map;
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int editCertificate(Map map) {
        return entryBackgroudMapper.editCertificate(map);
    }
    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int deleteCertificate(String allId) {
        String[] ids1 = allId.split(",");
        int num = 0;
        for (String id : ids1) {
            num += entryBackgroudMapper.deleteCertificate(id);
        }
        return num;
    }
}
